<template>
  <a-tree-select
    v-model="formModel"
    allow-clear
    multiple
    :field-names="fieldNames"
    :data="deptList"
    placeholder="请选择"
  >
    <template #tree-slot-icon>
      <icon-folder />
    </template>
  </a-tree-select>
</template>

<script lang="ts" setup>
import { ref, defineModel, onMounted } from 'vue';
import { deptTree } from '@/api/system/dept';

const formModel = defineModel({ type: Array });

const deptList = ref();

const fieldNames = ref({
  key: 'deptId',
  title: 'deptName',
  children: 'children'
});

onMounted(() => {
  deptTree(false).then(res => {
    deptList.value = res.data;
  });
});
</script>

<script lang="ts">
export default {
  name: 'BusinessDeptSelect'
};
</script>

<style scoped lang="less">

</style>